from yahoo.search.web import WebSearch

app_id = "NQ0jPsbV34EKDAqvHpDPN2oQCfzKryHu4ryznZbHTJKrgScaqe1KmIORmufdUA--"
class SearchEngineManager:
    """This class will handle all search-engine related things."""
    
    def __init__(self, query=None, maxresults=10):
        """Initialize the SearchEngineManager"""
        self.query = query
        self.results = None # Stores the parsed results of the query
        self.maxresults = maxresults; # Defaults is 10 results per query
        
    def setSearchQuery(self, querystring):
        """Sets the Search Query that will be executed"""
        self.query = querystring
        
    def getSearchQuery(self):
        """Gets the search query"""
        return self.query
    
    def setMaxResults(self, maxresults):
        """Sets the number of results that should be returned"""
        self.maxresults = maxresults
        
    def getMaxResults(self):
        """Returns the max results per query"""
        return self.maxresults
    
    def executeQuery(self):
        """executes the search query"""
        srch = WebSearch(app_id)
        srch.query = self.getSearchQuery()
        srch.results = self.getMaxResults()
        self.results = srch.parse_results()
        
    def getResults(self):
        """Returns the search query results"""
        return self.results
    
